package at.fhj.itm11.antesk.memory.view;

import java.awt.GridLayout;
import javax.swing.JPanel;

import at.fhj.itm11.antesk.memory.model.Field;
import at.fhj.itm11.antesk.memory.model.Logic;

/**
 * Panel that contains all fields.
 * 
 * @author Ivan Antes-Klobucar
 * @version 1.0
 *
 */
public class FieldPanel extends JPanel{

	private static final long serialVersionUID = 6419109006237024254L;
	private Logic logic;
	private Field[] fields;
	
	public Field[] getFields() {
		return fields;
	}

	/**
	 * Default constructor for FieldPanel.
	 * 
	 * @param rows Number of rows on the field
	 * @param cols Number of columns on the field
	 */
	public FieldPanel(int rows, int cols) {
		setLayout(new GridLayout(rows, cols));
		logic = Logic.getInstance();
		fields = logic.getField();
		fields = logic.shuffleFields(fields);
		
		for(int i = 0; i <= fields.length - 1; i++){
			add( new Field( fields[i].getId() ) );
		}
		
	}
}
